package com.htc.android.footprints.utils;

import java.util.HashMap;

import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.ResultReceiver;
import android.util.Log;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;

public class ImeLauncher
{
  private static String TAG = "ImeLauncher";
  private static ImeLauncher instance = null;
  private HashMap<Integer, LaunchImeReceiver> mImeReceivers = new HashMap();
  private InputMethodManager mInputManager;

  private ImeLauncher(Context paramContext)
  {
    this.mInputManager = ((InputMethodManager)paramContext.getSystemService("input_method"));
  }

  public static ImeLauncher getInstance(Context paramContext)
  {
    if (instance == null)
      instance = new ImeLauncher(paramContext);
    return instance;
  }

  public void hide(EditText paramEditText)
  {
    if (paramEditText == null);
    while (true)
    {
      return;
      this.mInputManager.hideSoftInputFromWindow(paramEditText.getWindowToken(), 0);
    }
  }

  public void show(EditText paramEditText)
  {
    if (paramEditText == null);
    while (true)
    {
      return;
      int i = paramEditText.hashCode();
      LaunchImeReceiver localLaunchImeReceiver = (LaunchImeReceiver)this.mImeReceivers.get(Integer.valueOf(i));
      if (localLaunchImeReceiver == null)
      {
        localLaunchImeReceiver = new LaunchImeReceiver(this.mInputManager, paramEditText);
        this.mImeReceivers.put(Integer.valueOf(i), localLaunchImeReceiver);
      }
      if (this.mInputManager.showSoftInput(paramEditText, 0, localLaunchImeReceiver))
        continue;
      localLaunchImeReceiver.send(3, null);
    }
  }

  protected static class LaunchImeReceiver extends ResultReceiver
  {
    private EditText mEditText;
    private InputMethodManager mImManager;
    private int mRetryCount = 0;

    LaunchImeReceiver(InputMethodManager paramInputMethodManager, EditText paramEditText)
    {
      super();
      this.mImManager = paramInputMethodManager;
      this.mEditText = paramEditText;
    }

    private void relaunchIme()
    {
      new Handler().post(new Runnable()
      {
        public void run()
        {
          ImeLauncher.LaunchImeReceiver.access$008(ImeLauncher.LaunchImeReceiver.this);
          if (!ImeLauncher.LaunchImeReceiver.this.mImManager.showSoftInput(ImeLauncher.LaunchImeReceiver.this.mEditText, 0, ImeLauncher.LaunchImeReceiver.this))
            ImeLauncher.LaunchImeReceiver.this.send(3, null);
        }
      });
    }

    protected void onReceiveResult(int paramInt, Bundle paramBundle)
    {
      switch (paramInt)
      {
      default:
      case 1:
      case 3:
      case 0:
      case 2:
      }
      while (true)
      {
        return;
        if (this.mRetryCount < 5)
          Log.w(ImeLauncher.TAG, "Launch IME failed, retryCount=" + this.mRetryCount);
        relaunchIme();
        continue;
        this.mRetryCount = 0;
      }
    }
  }
}

/* Location:           E:\workspace\dex2java\dex-translator-0.0.9.3\HtcFootprints_dex2jar.jar
 * Qualified Name:     com.htc.android.footprints.utils.ImeLauncher
 * JD-Core Version:    0.6.0
 */